package com.neusoft.shopingapi.dao;

import com.neusoft.shopingapi.entity.PictureEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class PictureDAOImpl {
    @Autowired
    private JdbcTemplate jdbcTemplate;

    public List<PictureEntity> qureyOneAll(Integer goodsno ){
        String  sql="select *from pictureinfo where goodsno=?";
        RowMapper<PictureEntity> rowMapper=new BeanPropertyRowMapper<>(PictureEntity.class);
        return jdbcTemplate.query(sql,rowMapper,goodsno);
    }

    public List<PictureEntity>  qureyFirst(Integer goodsno){
        String  sql="select *from pictureinfo where goodsno=? and isfirst='Y'";
        RowMapper<PictureEntity> rowMapper=new BeanPropertyRowMapper<>(PictureEntity.class);
        return jdbcTemplate.query(sql,rowMapper,goodsno);
    }

}
